package net.lab1024.sa.admin.module.sast.rule.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.websocket.server.PathParam;
import net.lab1024.sa.admin.module.sast.rule.domain.RuleCategoryCountVO;
import net.lab1024.sa.admin.module.sast.rule.domain.RuleDetailVO;
import net.lab1024.sa.admin.module.sast.rule.domain.RuleQueryForm;
import net.lab1024.sa.admin.module.sast.rule.domain.RuleVO;
import net.lab1024.sa.admin.module.sast.rule.service.RuleService;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目管理
 */
@RestController
@RequestMapping("/rule")
@Tag(name = "规则管理")
public class RuleController {

    @Resource
    private RuleService ruleService;
    @Operation(summary = "分页查询规则信息")
    @PostMapping("/query")
//    @SaCheckPermission("rule:query")
    public ResponseDTO<PageResult<RuleVO>> queryProjects(@RequestBody RuleQueryForm ruleQueryForm) {
        return ruleService.query(ruleQueryForm);
    }

    @Operation(summary = "查询规则详细信息")
    @GetMapping("/query/{uuid}")
    public ResponseDTO<RuleDetailVO> queryById(@PathVariable String uuid) {
        return ruleService.getByUuid(uuid);
    }

    @Operation(summary = "按类型分组获取分类数量列表")
    @GetMapping("/countByType")
    public ResponseDTO<List<RuleCategoryCountVO>> getRuleCountByType(@PathParam("category")String category) {
        return ruleService.getCategoryCountList(category);
    }
    @Operation(summary = "获取规则总数")
    @GetMapping("/totalCount")
    public ResponseDTO<?> getRuleCount() {
        return ruleService.getRuleCount();
    }
}
